package org.jeecg.modules.complain.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.common.util.CommonDefine;
import org.jeecg.modules.complain.entity.ComplainStatus;
import org.jeecg.modules.complain.mapper.ComplainStatusMapper;
import org.jeecg.modules.complain.service.IComplainStatusService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

/**
 * @Description: 投诉配置
 * @Author: jeecg-boot
 * @Date:   2019-09-03
 * @Version: V1.0
 */
@Service
public class ComplainStatusServiceImpl extends ServiceImpl<ComplainStatusMapper, ComplainStatus> implements IComplainStatusService {
    @Autowired
    private ComplainStatusMapper complainStatusMapper;
    @Override
    public ComplainStatus selectStatus(String complainId, Integer status) {
        return complainStatusMapper.selectStatus(complainId,status);
    }

    @Override
    public Integer deletStatus(ComplainStatus complainStatus,Integer source) {
           complainStatusMapper.deleteByComplainId(complainStatus);
           complainStatus.setId(null);
           if (source == 0){
               complainStatus.setDelFlag("1");
               complainStatus.setStatus(CommonDefine.COMPLAIN_STATUS_200);
               complainStatusMapper.insert(complainStatus);
               complainStatus.setId(null);
               complainStatus.setCreateTime(null);
               complainStatus.setReturnContents(null);
               complainStatus.setDelFlag("0");
               complainStatus.setStatus(CommonDefine.COMPLAIN_STATUS_300);
           }else {
           complainStatus.setStatus(CommonDefine.COMPLAIN_STATUS_200);
           }
        int flag = complainStatusMapper.insert(complainStatus);
        return  flag;
    }

    @Override
    public List<ComplainStatus> selectAll(String complainId) {
        return complainStatusMapper.selectAll(complainId);
    }
}
